package com.huazai.service.impl;

import com.huazai.bean.po.Books;
import com.huazai.dao.BooksMapper;
import com.huazai.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Qualifier("BookServiceImpl")
public class BookServiceImpl implements BookService {

    private BooksMapper booksMapper;

    @Autowired
    public void setBooksMapper(BooksMapper booksMapper) {
        this.booksMapper = booksMapper;
    }

    @Override
    public Boolean addBook(Books books) {
        return booksMapper.addBook(books);
    }

    @Override
    public Boolean deleteBook(String bookID) {
        return booksMapper.deleteBook(bookID);
    }

    @Override
    public Boolean updateBook(Books books) {
        return booksMapper.updateBook(books);
    }

    @Override
    public List<Books> selectBook(Long bookID, String bookName) {
        Map<String, String> map = new HashMap<>();

        if (bookID != null) {
            map.put("bookID", bookID.toString());
        }
        map.put("queryBookName", bookName);

        return booksMapper.selectBook(map);
    }
}
